<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%
    String path = request.getContextPath(); 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+path+ "/"; 

%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>添加老师</title>
	<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/bootstrap-datetimepicker.css" />
    <link rel="stylesheet" href="bootstrap-table/dist/bootstrap-table.css">
    <link rel="stylesheet" type="text/css" href="css/xcConfirm.css" />
	<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />
	<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
	<link rel="stylesheet" href="bootstrap-fileinput-master/css/fileinput.min.css">
	<link href="umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/x-admin.css">
    
    <style type="text/css">
        #panel {
            position: absolute;
            background-color: white;
            max-height: 90%;
            overflow-y: auto;
            top: 10px;
            right: 10px;
            width: 280px;
        }
        .td1{
			float:left;
			width:50px;
			display: block; 
			valign:middle;
		}
		.td2{
			float:left;
			width:200px;
			display: block; 
			valign:middle;
		}
		.td3{
			float:left;
			width:660px;
			display: block; 
			valign:middle;
		}
    </style>
</head>
<body>
	<div class="x-body">
            <div   class="form-horizontal" role="form">
			  	<div class="form-group">
			    <label for="firstname" class="col-sm-2 control-label">分类图标:</label>
			    <div class="col-sm-3">
			    	<input id="upload"  type="file" name="file" multiple class="file-loading">
					<input id="cover" name="cover" type="hidden">
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <label for="firstname" class="col-sm-2 control-label">分类名称:</label>
			    <div class="col-sm-3">
			      <input type="text" class="form-control" id="G_NAME" name="G_NAME" required="required" placeholder="请输入分类名称"/>
			    </div>
			  </div>
     	<div class="form-group" style="padding-left: 30%">
        <button type="submit"   onclick="save()"  class="btn btn-info" >保存</button>
        <button type="reset"    onclick="cancel()"  class="btn btn-info" >取消 </button>
   
     </div>
          </div>
	</div>
        <script src="lib/layui/layui.js" charset="utf-8"></script>
        <script src="js/x-layui.js" charset="utf-8"></script>
        <!-- 加载需要的js -->
		<script src="js/jquery-3.2.1.min.js"></script>
		<script src="js/common2.js"></script>
		<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
		<script src="js/jquery-bootstrap-pagination.js"></script>
		<script src="js/qunit-1.11.0.js"></script>
		<script src="js/bootstrap-datetimepicker.js"></script>
		<script src="js/bootstrap-datetimepicker.zh-CN.js"></script>
	    <script src="js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>
	    <script src="bootstrap-fileinput-master/js/fileinput.min.js"></script>
		<script src="bootstrap-fileinput-master/js/locales/zh.js"></script>
		
		<script type="text/javascript" src="umeditor/third-party/template.min.js"></script>
    	<script type="text/javascript" charset="utf-8" src="umeditor/umeditor.config.js"></script>
    	<script type="text/javascript" charset="utf-8" src="umeditor/umeditor.min.js"></script>
    	<script type="text/javascript" src="umeditor/lang/zh-cn/zh-cn.js"></script>
        <script>
       /*  $(function(){
       		$.ajax({
    	        type: "get",
    	        url: "courseInfo/selectTprofessionSort",
    	        dataType:"json",
    	        success: function(data){    
    	      	  if(data.code==200){	           	              
    	      		var htm='';
    	     		for (var i = 0; i < data.data.length; i++) {
    	   				var bean = data.data;
    	   				htm += '<tr style="margin-left:20px;display:inline-block;"><td><input class="start_the_boot" type="checkbox" name="actionId" value="10"/>'+bean[i].G_TITLE+'</td></tr>'
    				}
    	     		$("#skill").html(htm);
    	   	 	  }
    	 	      
    	        }
    	    });
       	   }); */
        
            layui.use(['form','layer','upload'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
              });
            
          //时间插件
    		$('.form_date').datetimepicker({
    	        language:  'zh-CN',
    	        weekStart: 1,
    	        todayBtn:  1,
    			autoclose: 1,
    			todayHighlight: 1,
    			startView: 2,
    			minView: 2,
    			forceParse: 0
    	    });
            $("#upload").fileinput({
            	 uploadUrl: "upload/photoImg",
     		    uploadAsync: true,
     		    maxFileCount: 1,
//    		    initialPreview: [ 
// 			    	'<img src="${result.G_IMG}"  id="img"  class="file-preview-image"  width="256px" height="160px" />',
// 			    	],
//     		    overwriteInitial: ture,
//     			    initialPreview: [ "http://lorempixel.com/800/460/people/1"],
//     			    initialPreviewAsData: true, // identify if you are sending preview data only and not the raw markup
//     			    initialPreviewFileType: 'image', // image is the default and can be overridden in config below
//     			    initialPreviewConfig: [
//     			       {caption: "People-1.jpg", size: 576237, width: "120px", url: "/site/file-delete", key: 1},
//     			    ],
//     			    uploadExtraData: {
//     			        img_key: "1000",
//     			        img_keywords: "happy, places",
//     			    }
    		}).on('fileuploaded', function(event, data, previewId, index) {
    		    var form = data.form, files = data.files, extra = data.extra,
    	        response = data.response, reader = data.reader;
    			if(response.data != null && response.data != ""){
    		    	$("#cover").val(response.data);			
    			}else{
    				alert("图片服务器异常，请重新上传！");
    			}
    		});
            
            function deleteRow(e)
            {
             e=e||event;
             var btn=e.srcElement||e.target;
             btn.parentNode.parentNode.parentNode.removeChild(btn.parentNode.parentNode);
            }
            
            function divClick(){    
    		    
      	       var show="";    
      	       var apm = document.getElementsByName("hasGroup");    
      	       for(var i=0;i<apm.length;i++){    
      	       if(apm[i].checked)    
      	        show = apm[i].value;    
      	       }    
      	         
      	       switch (show){    
      	           case '0':    
      	               document.getElementById("com").style.display="none";    
      	               break;    
      	           default:    
      	               document.getElementById("com").style.display="block";    
      	               break;                                                       
      	       }    
      	}

             $(function(){
             	
             	var show="";    
       	       var apm = document.getElementsByName("hasGroup");    
       	       for(var i=0;i<apm.length;i++){    
       	       if(apm[i].checked)    
       	        show = apm[i].value;    
       	       }    
       	         
       	       switch (show){    
       	           case '0':    
       	               document.getElementById("com").style.display="none";    
       	               break;    
       	           default:    
       	               document.getElementById("com").style.display="block";    
       	               break;                                                       
       	       }    
             	
             });

            
            function save(){
            	var G_IMG = $("#cover").val();
      		   	 if(G_IMG == null||G_IMG=="") {
      		   		layer.msg('分类图标不能为空!',{icon:2,time:2000});
      				  return ;
      		   	 }
            	
             var G_NAME = $("#G_NAME").val();
   			 if(G_NAME == null||G_NAME=="") {
   				layer.msg('分类名称不能为空!',{icon:2,time:2000});
 				  return ;
   		   	 }
			
   	         $.ajax({
   	             type: "post",
   	             url: "commonSort/insertOneSort",
   	             data:{
   	            	G_IMG:G_IMG,
   	            	G_NAME:G_NAME,
   	             },
   	             dataType:"json",
   	             success: function(data){    
   	            	if(data.code == 200){
   	    	           	layer.alert("添加成功", {icon: 6},function () {
   	    	           		parent.location.reload();
   	 	                    // 获得frame索引
   	 	                    var index = parent.layer.getFrameIndex(window.name);
   	 	                    //关闭当前frame
   	 	                    parent.layer.close(index);
   	 	                     parent.location.reload();
   	 	                });    
   	 	       		}else{
   	 	    	      	var txt=data.msg;
   	 	      	    	 layer.alert(txt); 
   	 	      	    }
   	             }
   	         });  
   	         
   			}
   	   
   	   function cancel(){
   		   	
   		// 获得frame索引
           var index = parent.layer.getFrameIndex(window.name);
           //关闭当前frame
           parent.layer.close(index);
   	         
   			}
   	   
   	   $(function(){
   		   
   		$.ajax({
	        type: "get",
	        url: "common/videoTypes",
	        data:{
	      	  type:5,
	        },
	        dataType:"json",
	        success: function(data){    
	       	
	      	  if(data.code==200){	           	              
	      		var htm='';
	      		    htm +='<option value=" ">请选择视频类别</option>';
	     		for (var i = 0; i < data.data.length; i++) {
		   				var bean = data.data;
		   				htm +='<option value="'+bean[i].id+'">'+bean[i].name+'</option>';
					}
	     		$("#type").html(htm);
	   	 	  }
	 	      
	        }
	    });
   	   });
        		
   	   
   	function changePhone() {
		var country = $("#type").find("option:selected").val();
		if(country == null) {
			var htm='';
  		    htm +='<option value=" ">请选择</option>';
			return $("#country").html(htm);
		}
		
		 $.ajax({
            type: "get",
            url: "common/studyCountryList",
            dataType:"json",
            data:{type:country},
            success: function(data){    
           	
          	  if(data.code==200){	           	              
          		var htm='';
          		    htm +='<option value=" ">请选择</option>';
         		for (var i = 0; i < data.data.length; i++) {
	   				var bean = data.data;
	   				htm +='<option value="'+bean[i].id+'" code="'+bean[i].name+'">'+bean[i].name+'</option>';
  				}
         		$("#country").html(htm);
       	 	  }
     	      
            }
        });  
	}
   	   
   	layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
      laydate = layui.laydate;//日期插件
      lement = layui.element();//面包导航
      laypage = layui.laypage;//分页
      layer = layui.layer;//弹出层

      //以上模块根据需要引入
      var start = {
        min: '2000-01-01 00:00:00'
        ,max: '2099-06-16 23:59:59'
        ,istoday: false
        ,choose: function(datas){
          end.min = datas; //开始日选好后，重置结束日的最小日期
          end.start = datas //将结束日的初始值设定为开始日
        }
      };
      
      var end = {
        min: '2000-01-01 00:00:00'
        ,max: '2099-06-16 23:59:59'
        ,istoday: false
        ,choose: function(datas){
          start.max = datas; //结束日选好后，重置开始日的最大日期
        }
      };
      
      var end1 = {
    	        min: '2000-01-01 00:00:00'
    	        ,max: '2099-06-16 23:59:59'
    	        ,istoday: false
    	        ,choose: function(datas){
    	          start.max = datas; //结束日选好后，重置开始日的最大日期
    	        }
    	      };
      
      document.getElementById('LAY_demorange_s').onclick = function(){
        start.elem = this;
        laydate(start);
      }
      
    });
   	
        </script>
        <script type="text/javascript">
    	//实例化编辑器
    	var um = UM.getEditor('myEditor');
    	//失去焦点
    	um.addListener('blur',function(){
    	//判断是否有内容
        if(UM.getEditor('myEditor').hasContents()){
        	$("#infomationContent").val(UM.getEditor('myEditor').getContent());
        }
   	 	});
    	//获得焦点
    	um.addListener('focus',function(){
        
    	});
     	//营销管理
     	
	</script>
</body>
</html>